package org.neurone.action.session;

import org.neurone.action.BaseActionSupport;
import org.neurone.session.ApplicationSession;
import org.neurone.session.SessionHive;
import org.neurone.session.impl.ApplicationSessionLocal;

public class SessionCheckAction extends BaseActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6181674836379110695L;

	private String targetURL;
	private String appKey;

	private ApplicationSession applicationSession;
	
	public String getTargetURL() {
		return targetURL;
	}
	public void setTargetURL(String targetURL) {
		this.targetURL = targetURL;
	}
		
	public String getAppKey() {
		return appKey;
	}
	public void setAppKey(String appKey) {
		this.appKey = appKey;
	}

	public ApplicationSession getApplicationSession() {
		return applicationSession;
	}
	public void setApplicationSession(ApplicationSession applicationSession) {
		this.applicationSession = applicationSession;
	}
	public String checkSession()
	{
		if(this.applicationSession == null)
		{
			this.applicationSession = new ApplicationSessionLocal();
		}
		
		if(super.checkNowSession() != null)
		{
			return success(applicationSession.createSessionToken(targetURL, appKey,this.sessionHive.getNewToken()));
		}else
		{
			return LOGIN;
		}
	}
	
	public String loginJump()
	{
		return success("loginjump");
	}
}
